package com.axdoc.walletbiz.record.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.axdoc.walletbiz.record.service.impl.DataServiceImpl;
import com.axdoc.walletbiz.record.utils.SpringContextUtil;

/**
 * 异步处理追历史数据
 * 
 * @author sunzhaoli
 *
 */
public class DataAsync {

	public static Logger logger = LoggerFactory.getLogger("data");

	/**
	 * 类型：1时间点之前的2时间点之后的
	 */
	private int type;
	/**
	 * 时间
	 */
	private String time;

	public DataAsync(int type, String time) {
		super();
		this.type = type;
		this.time = time;
	}

	public void doData() {
		// 新定义线程来处理发送
		new Thread() {
			public void run() {
				try {
					DataServiceImpl service = (DataServiceImpl) SpringContextUtil.getBean("dataService");
					if (type == 1) {
						service.dataBeforeBack(time);
					}
					if (type == 2) {
						service.dataAfterBack(time);
					}
				} catch (Exception e) {
					logger.error("error=", e);
				}
			}
		}.start();
	}

}
